const webpack = require("webpack")
// const CopyWebpackPlugin = require('copy-webpack-plugin')
const merge = require("webpack-merge")
const base = require("./index")

module.exports = function(env) {
  let devConfig = {
    mode: "development",
    devtool: "source-map",
    devServer: {
      host: "0.0.0.0",
      inline: true,
      clientLogLevel: "error",
      open: false,
      hot: true,
      lazy: false,
      historyApiFallback: {
        rewrites: { from: /./, to: "/404.html" }
      },
      overlay: {
        warnings: true,
        errors: true
      },
      stats: "errors-only",
      proxy: {
        "/": {
          target: "https://jsonplaceholder.typicode.com"
        }
      }
    },
    plugins: [new webpack.NamedModulesPlugin(), new webpack.HotModuleReplacementPlugin()],
    optimization: {
      splitChunks: {
        name: "vendor",
        chunks: "all"
      }
    }
  }

  devConfig = merge(base(env), devConfig)

  return devConfig
}
